package com.yida.wy.vote.outside.service.impl;

import com.yida.common.core.utils.DateUtils;
import com.yida.common.security.utils.SecurityUtils;
import com.yida.wy.vote.outside.domain.WyVoteBuild;
import com.yida.wy.vote.outside.mapper.WyVoteBuildMapper;
import com.yida.wy.vote.outside.service.IWyVoteBuildService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 投票楼栋Service业务层处理
 *
 * @author lqq
 * @date 2023-03-22
 */
@Service
public class WyVoteBuildServiceImpl implements IWyVoteBuildService {

	@Resource
	private WyVoteBuildMapper voteBuildMapper;

	/**
	 * 查询投票楼栋
	 *
	 * @param voteBuildId 投票楼栋主键
	 * @return 投票楼栋
	 */
	@Override
	public WyVoteBuild selectVoteBuildByVoteBuildId(Long voteBuildId) {
		return voteBuildMapper.selectVoteBuildByVoteBuildId(voteBuildId);
	}

	/**
	 * 查询投票楼栋
	 *
	 * @param buildId 投票楼栋主键
	 * @param voteId  投票ID
	 * @return 投票楼栋
	 */
	@Override
	public WyVoteBuild selectVoteBuildByBuildIdAndVoteId(Long buildId, Long voteId) {
		return voteBuildMapper.selectVoteBuildByBuildIdAndVoteId(buildId, voteId);
	}

	/**
	 * 查询投票楼栋列表
	 *
	 * @param voteBuild 投票楼栋
	 * @return 投票楼栋
	 */
	@Override
	public List<WyVoteBuild> selectVoteBuildList(WyVoteBuild voteBuild) {
		return voteBuildMapper.selectVoteBuildList(voteBuild);
	}

	/**
	 * 新增投票楼栋
	 *
	 * @param voteBuild 投票楼栋
	 * @return 结果
	 */
	@Override
	public int insertVoteBuild(WyVoteBuild voteBuild) {
		voteBuild.setCreateBy(SecurityUtils.getLoginUser().getSysOutsideUser().getRealName());
		voteBuild.setCreateTime(DateUtils.getNowDate());
		return voteBuildMapper.insertVoteBuild(voteBuild);
	}

	/**
	 * 新增投票楼栋
	 *
	 * @param voteBuilds 投票楼栋
	 * @return 结果
	 */
	@Override
	public int insertBatchVoteBuild(List<WyVoteBuild> voteBuilds) {
		return voteBuildMapper.insertBatchVoteBuild(voteBuilds);
	}

	/**
	 * 修改投票楼栋
	 *
	 * @param voteBuild 投票楼栋
	 * @return 结果
	 */
	@Override
	public int updateVoteBuild(WyVoteBuild voteBuild) {
		voteBuild.setUpdateBy(SecurityUtils.getLoginUser().getSysOutsideUser().getRealName());
		voteBuild.setUpdateTime(DateUtils.getNowDate());
		return voteBuildMapper.updateVoteBuild(voteBuild);
	}

	/**
	 * 批量删除投票楼栋
	 *
	 * @param voteBuildIds 需要删除的投票楼栋主键
	 * @return 结果
	 */
	@Override
	public int deleteVoteBuildByVoteBuildIds(Long[] voteBuildIds) {
		return voteBuildMapper.deleteVoteBuildByVoteBuildIds(voteBuildIds);
	}

	/**
	 * 删除投票楼栋信息
	 *
	 * @param voteBuildId 投票楼栋主键
	 * @return 结果
	 */
	@Override
	public int deleteVoteBuildByVoteBuildId(Long voteBuildId) {
		return voteBuildMapper.deleteVoteBuildByVoteBuildId(voteBuildId);
	}
}
